package main

import (
	"os"
	"os/signal"
	"syscall"
	_ "zhou_gin_api/app/validate"
	"zhou_gin_api/appLog"
	_ "zhou_gin_api/appLog"
	"zhou_gin_api/config"
	"zhou_gin_api/datasource"
	"zhou_gin_api/router"
	"zhou_gin_api/utils"
)

func main() {

	config.InitConfig() //初始化配置
	utils.InitUtilsConfig()

	//初始化数据库
	db := datasource.NewDbMaster()
	datasource.SetInstanceDb(db)
	defer db.Close()

	//初始化redis
	datasource.InstanceCache()
	appLog.InfoSimpleLog("启动成功")
	//开启gin应用
	router.HttpServerRun()

	quit := make(chan os.Signal)
	signal.Notify(quit, syscall.SIGKILL, syscall.SIGQUIT, syscall.SIGINT, syscall.SIGTERM)
	<-quit

	router.HttpServerStop()

}
